@extends('Admin.Layout.main')
@section('privateheader')
    <!-- DataTables -->
    <link rel="stylesheet" href="{{__BASE__}}/admin/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="{{__BASE__}}/admin/plugins/treetable/css/jquery.treeTable.css">
@endsection
@section('content')
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        @if($data['flag'] == 3)
                            <h3 class="box-title">用户组管理</h3>
                            <a class="btn bg-olive" href="{{__BASE__}}/admini/adminusergroup/create">用户组添加</a>
                            <a class="btn bg-red" href="{{__BASE__}}/admini/adminusergroup/rb">回收站</a>
                        @elseif($data['flag'] == 4)
                            <h3 class="box-title">用户组管理回收站</h3>
                            <a class="btn bg-olive" href="{{__BASE__}}/admini/adminusergroup">用户组管理</a>
                        @endif
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-striped" id="treeTable2">
                            <thead>
                            <tr>
                                <th>用户组名称</th>
                                <th>用户组ID</th>
                                <th>所属父级栏目名称</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if(!empty($data['list']))
                                @foreach($data['list'] as $v)
                                    <tr id="{{$v['id']}}" <?php echo $v['pid'] != '' ? 'pId="'.$v['pid'].'"' : '';?> >
                                        <td>&nbsp;&nbsp;<?php echo !empty($v['id']) && $v['id'] == 1 ? '<font color="red">'.$v['name'].'</font>' : $v['name'];?></td>
                                        <td>{{$v['id'] or ''}}</td>
                                        <td>{{$v['pidname'] or '顶级'}}</td>
                                        <td>
                                            @if($data['flag'] == 3 && $v['id'] != 1)
                                                <button class="btn bg-olive seturl" type="button" seturl="/admini/adminusergroup/{{$v['id'] or ''}}/set">设置组权限</button>
                                                <button class="btn bg-olive" type="button" onclick="javascript:location.href='/admini/adminusergroup/create?pid={{$v['id'] or 0}}'">添加</button>
                                                <button class="btn bg-orange" type="button" onclick="javascript:location.href='/admini/adminusergroup/{{$v['id'] or ''}}/edit'">修改</button>
                                                <button class="btn bg-red delbutton" type="button" delurl="/admini/adminusergroup/{{$v['id'] or ''}}" skipurl="/admini/adminusergroup" ac="1">删除</button>
                                            @elseif($data['flag'] == 4)
                                                <button class="btn bg-orange delbutton" type="button" delurl="/admini/adminusergroup/{{$v['id'] or ''}}" skipurl="/admini/adminusergroup" ac="3">还原</button>
                                                <button class="btn bg-red delbutton" type="button" delurl="/admini/adminusergroup/{{$v['id'] or ''}}" skipurl="/admini/adminusergroup" ac="2">删除</button>
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
@endsection
@section('privatefooter')
    <script src="{{__BASE__}}/admin/plugins/treetable/js/jquery.treeTable.js" type="text/javascript"></script>
    <!-- /.content -->
    <script type="text/javascript">
        $(function(){
            @if($data['flag'] != 4)
                var option = {
                            theme:'vsStyle',
                            expandLevel : 2
                        };
                option.theme = 'default';
                $('#treeTable2').treeTable(option);
            @endif

            $(".seturl").on("click",function(){
                var seturl = $(this).attr("seturl");
                location.href=seturl;
            });
        });
    </script>
@endsection